package com.goldenautumn.prefabricate.activity.mine.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.business.entity.LanguageInfoVo
import com.goldenautumn.prefabricate.databinding.ItemLanguageBinding
import qncx.external.common.compat.isVisible

class LanguageAdapter  : BaseQuickAdapter<LanguageInfoVo, DataBindingHolder<ItemLanguageBinding>>() {

    var selectPosition = -1

    override fun onBindViewHolder(holder: DataBindingHolder<ItemLanguageBinding>, position: Int, item: LanguageInfoVo?) {
        if (item == null) return
        var mBinding = holder.binding
        mBinding.selectBtn.isVisible(selectPosition == position)
        mBinding.type.text = "${item.language}"
        mBinding.title.text = "${item.title}"
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): DataBindingHolder<ItemLanguageBinding> {
        return DataBindingHolder(R.layout.item_language, parent)
    }
}